package store

import (
	"context"
	"github.com/go-redis/redis/v8"
)

type RedisHash struct {
	key    string
	client *redis.Client
	ctx    context.Context
}

func NewRedisHash(key string, client *redis.Client) *RedisHash {
	return &RedisHash{
		key:    key,
		client: client,
		ctx:    context.Background(),
	}
}

func (h *RedisHash) HSet(value interface{}) {
	h.client.HSet(h.ctx, h.key, value)
}

func (h *RedisHash) HGet(field string) (string, error) {
	value, err := h.client.HGet(h.ctx, h.key, field).Result()
	return value, err
}
